package life.huangzhi.community.community.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**拦截器*/
@Configuration
//@EnableWebMvc  要设置拦截排除的话（排除的是静态资源），不加这个注解
public class WebConfig implements WebMvcConfigurer {
    @Resource
    private  SessionInterceptor sessionInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //未登录时拦截所有请求，除静态资源外
        registry.addInterceptor(sessionInterceptor).addPathPatterns("/**").excludePathPatterns("/static/**");
    }
}
